package com.youchuang.action.user;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.youchuang.action.BaseAction;
import com.youchuang.bean.User;
import com.youchuang.common.Constant;
import com.youchuang.service.UserService;

/**
 * 修改用户信息
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/user")
@ParentPackage("shopping-default")
public class UpdateUserAction extends BaseAction {
	private Logger logger = Logger.getLogger(UpdateUserAction.class.getSimpleName());
	private User user;
	@Resource
	private UserService userService;

	@Action(value = "updateUser", results = {
			@Result(name = ActionSupport.SUCCESS, location = "/common/XYTipsWindowClose.jsp"),
			@Result(name = ActionSupport.ERROR, location = "/common/error.jsp") })
	public String execute() throws Exception {
		logger.info("execution is execute");
		logger.info("request json:" + user.toString());

		userService.updateUser(user);

		return Constant.SUCCESS;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
